package com.zaimokuza.cn.entity.exception;

import com.zaimokuza.cn.entity.enums.CustomizeExceptionEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义异常
 *
 * @author zaimokuza
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CustomizeException extends RuntimeException {

    private CustomizeExceptionEnum customizeExceptionEnum;

    private String resultMsg;

    public CustomizeException(CustomizeExceptionEnum customizeExceptionEnum) {
        super(String.format("异常状态码：[%s]，具体异常信息：[%s]", customizeExceptionEnum.getResultCode(), customizeExceptionEnum.getResultMsg()));
        this.customizeExceptionEnum = customizeExceptionEnum;
        this.resultMsg = customizeExceptionEnum.getResultMsg();
    }

    public CustomizeException(CustomizeExceptionEnum customizeExceptionEnum, String resultMsg) {
        super(String.format("异常状态码：[%s]，具体异常信息：[%s]", customizeExceptionEnum.getResultCode(), resultMsg));
        this.customizeExceptionEnum = customizeExceptionEnum;
        this.resultMsg = resultMsg;
    }

}
